<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>5.解构赋值新增特性</title>
</head>

<body>
  <script>
    //1. 对象使用
    /* let info = { name: '后盾人', url: 'houdunren.com' };
     let { name: n, url: u } = info
     console.log(n); // 后盾人 */

    //如果属性名与变量相同可以省略属性定义
    /*let { name, url } = { name: '后盾人', url: 'houdunren.com' };
    console.log(name); // 后盾人 */


    //2. 函数返回值直接解构到变量
    "use strict";
    /* function hd() {
      return {
        name: '后盾人',
        url: 'houdunren.com'
      };
    }
    let { name: n, url: u } = hd();
    console.log(n); */
    //3. 函数传参
    function hd({ name, age }) {
      console.log(name, age); //向军大叔 18
    }
    hd({ name: "向军", age: 18 });
  </script>
</body>

</html>